package com.android1.amarena2d.texture;

import com.badlogic.gdx.Files;

public class BitmapFontDef {

    String key;
    String fontfilepath;
    Files.FileType fontfileType;
    ManagedTexture managedTexture;
    boolean flip;


    public BitmapFontDef(String fontfilepath, Files.FileType fontfileType, ManagedTexture managedTexture) {
        this(fontfilepath, fontfileType, managedTexture, false);
    }

    public BitmapFontDef(String fontfilepath, Files.FileType fontfileType, ManagedTexture managedTexture, boolean flip) {
        this.fontfilepath = fontfilepath;
        this.fontfileType = fontfileType;
        this.managedTexture = managedTexture;
        this.flip = flip;
        this.key = createKey(this);
    }

    public static String createKey(BitmapFontDef bitmapFontDef) {
        return createKey(bitmapFontDef.fontfilepath, bitmapFontDef.fontfileType, bitmapFontDef.managedTexture, bitmapFontDef.flip);
    }

    public static String createKey(String path, Files.FileType fileType, ManagedTexture managedTexture, boolean flip) {
        return new StringBuilder(path).append(fileType).append(flip).append(managedTexture.getKey()).toString();
    }

    @Override
    public String toString() {
        return "BitmapFontDef{" +
                "key='" + key + '\'' +
                ", fontfilepath='" + fontfilepath + '\'' +
                ", fontfileType=" + fontfileType +
                ", managedTexture=" + managedTexture.toString() +
                '}';
    }
}